home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_08 / phillips / geometry.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-20  |  4.4 KB  |  162 lines

  1.  
  2.     /********************************************
  3.     *
  4.     *    file d:\cips\geometry.c
  5.     *
  6.     *    Functions: This file contains
  7.     *       main
  8.     *
  9.     *    Purpose:
  10.     *       This file contains the main calling
  11.     *       routine for geometric subroutines.
  12.     *
  13.     *    External Calls:
  14.     *       gin.c - get_image_name
  15.     *       tiff.c - read_tiff_header
  16.     *       geosubs.c - geometry
  17.     *                   arotate
  18.     *
  19.     *    Modifications:
  20.     *       26 October 1993 - created
  21.     *
  22.     ********************************************/
  23.  
  24. #include "cips.h"
  25.  
  26.  
  27. short the_image[ROWS][COLS];
  28. short out_image[ROWS][COLS];
  29.  
  30. main(argc, argv)
  31.    int argc;
  32.    char *argv[];
  33. {
  34.  
  35.    char   name[80], name2[80], type[80];
  36.    float  theta, x_stretch, y_stretch,
  37.           x_cross, y_cross;
  38.    int    bilinear, count, i, ie, il, j, le,
  39.           length, ll, width;
  40.    int    x_control, y_control;
  41.    short  m, n, x_displace, y_displace;
  42.    struct tiff_header_struct image_header;
  43.  
  44.    my_clear_text_screen();
  45.  
  46.  
  47.       /*************************************
  48.       *
  49.       *   This program will use a different
  50.       *   command line for each type of
  51.       *   call.
  52.       *
  53.       *   Print a usage statement that
  54.       *   gives an example of each type
  55.       *   of call.
  56.       *
  57.       *************************************/
  58.  
  59.    if(argc < 7){
  60.     printf("\n\nNot enough parameters:");
  61.     printf("\n");
  62.     printf("\n   Two Operations: ");
  63.     printf("\n      geometry  rotate");
  64.     printf("\n\n   Examples:");
  65.     printf("\n");
  66.     printf("\n   geometry in out geometry angle");
  67.     printf(" x-displace y-displace");
  68.     printf("\n            x-stretch y-stretch");
  69.     printf(" x-cross y-cross bilinear (1 or 0)");
  70.     printf("\n");
  71.     printf("\n   geometry in out rotate angle m n");
  72.     printf(" bilinear (1 or 0)");
  73.     printf("\n");
  74.     exit(0);
  75.    }
  76.  
  77.       /*************************************
  78.       *
  79.       *   Interpret the command line
  80.       *   depending on the type of call.
  81.       *
  82.       *************************************/
  83.  
  84.    if(strncmp(argv[3], "geometry", 3) == 0){
  85.       strcpy(name,  argv[1]);
  86.       strcpy(name2, argv[2]);
  87.       strcpy(type,  argv[3]);
  88.       theta      = atof(argv[4]);
  89.       x_displace = atoi(argv[5]);
  90.       y_displace = atoi(argv[6]);
  91.       x_stretch  = atof(argv[7]);
  92.       y_stretch  = atof(argv[8]);
  93.       x_cross    = atof(argv[9]);
  94.       y_cross    = atof(argv[10]);
  95.       bilinear   = atoi(argv[11]);
  96.    }
  97.  
  98.    if(strncmp(argv[3], "rotate", 3) == 0){
  99.       strcpy(name,  argv[1]);
  100.       strcpy(name2, argv[2]);
  101.       strcpy(type,  argv[3]);
  102.       theta    = atof(argv[4]);
  103.       m        = atoi(argv[5]);
  104.       n        = atoi(argv[6]);
  105.       bilinear = atoi(argv[7]);
  106.    }
  107.  
  108.    il = 1;
  109.    ie = 1;
  110.    ll = ROWS+1;
  111.    le = COLS+1;
  112.  
  113.    read_tiff_header(name, &image_header);
  114.  
  115.    length = (ROWS-10 + image_header.image_length)/ROWS;
  116.    width  = (COLS-10 +image_header.image_width)/COLS;
  117.    count  = 1;
  118.    printf("\nlength=%d  width=%d", length, width);
  119.  
  120.       /*************************************
  121.       *
  122.       *   Call the routines
  123.       *
  124.       *************************************/
  125.  
  126.    if(strncmp(type, "geometry", 3) == 0){
  127.       for(i=0; i<length; i++){
  128.          for(j=0; j<width; j++){
  129.            printf("\nrunning %d of %d",
  130.                    count, length*width);
  131.            count++;
  132.            printf("\ntype is %s", type);
  133.            geometry(name, name2, the_image, out_image,
  134.                    il+i*ROWS, ie+j*COLS,
  135.                    ll+i*ROWS, le+j*COLS,
  136.                    theta, x_stretch, y_stretch,
  137.                    x_displace, y_displace,
  138.                    x_cross, y_cross,
  139.                    bilinear);
  140.          }  /* ends loop over j */
  141.       }  /* ends loop over i */
  142.    }  /* ends if */
  143.  
  144.  
  145.  
  146.    if(strncmp(type, "rotate", 3) == 0){
  147.       for(i=0; i<length; i++){
  148.          for(j=0; j<width; j++){
  149.            printf("\nrunning %d of %d",
  150.                    count, length*width);
  151.            count++;
  152.            printf("\ntype is %s", type);
  153.            arotate(name, name2, the_image, out_image,
  154.                   il+i*ROWS, ie+j*COLS,
  155.                   ll+i*ROWS, le+j*COLS,
  156.                   theta, m, n, bilinear);
  157.          }  /* ends loop over j */
  158.       }  /* ends loop over i */
  159.    }  /* ends if */
  160.  
  161. }  /* ends main  */
  162.